﻿function dd() {
    alert(8);
}




function submitOfUserControlClicked(event) {

    var sender = (event && event.target) || (window.event && window.event.srcElement);

    //get input
    var userNameInput = document.getElementById(sender.id + 'UserName');
    var passwordInput = document.getElementById(sender.id + 'Password');


    if (userNameInput.value == '' || passwordInput.value == '') {
       
        var userNameLabel = document.getElementById(sender.id + 'lblUserNameValidate');
        var passwordLabel = document.getElementById(sender.id + 'lblPasswordValidate');
        
        if (userNameInput.value == '') 
            userNameLabel.style['display'] = 'inline';
        else
            userNameLabel.style['display'] = 'none';
        
        if (passwordInput.value == '')
            passwordLabel.style['display'] = 'inline';
        else
            passwordLabel.style['display'] = 'none';
        event.preventDefault();
    }
    else {
        var resualt = confirm('Are you sure?');

        if (!resualt) {
            alert('Data was not sended');
            event.preventDefault();
        }
        else {
            alert('Data was sended');
         }
     }

};

document.addEventListener('DOMContentLoaded', function () {

    //add handler to button
     var submits = document.getElementsByClassName('submitOfServerControl');
    //var submits = document.getElementById('ServerControlSubmit');

    var i;
    for (i = 0; i < submits.length; i++) {
        submits[i].addEventListener('click', submitOfUserControlClicked, false);
    }
}, false);

